home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / docs / howto / understandTheFileSystem < prev    next >
Encoding:
Text File  |  1992-12-14  |  42.5 KB  |  1,053 lines

  1. This file describes various indirection tables used in the file system.
  2. I hope that this will be useful when trying to follow the
  3. control flow through function tables.  The things here are ripped out
  4. of various source files.
  5. --Ken Shirriff 7/90
  6.  
  7. ******************************************************************************
  8. But before we get to that, here is a map of what happens on an Fs_Open call.
  9. This traces the path through the different switch tables.  The Fs_Open call
  10. has three main components, as numbered below.  The two most important,
  11. the lookup (and name open) and io open sections, are traced separately, as
  12. numbered.      --Mary Baker 9/91
  13.  
  14.     Here is the format of this map:  if procedure A calls procedures
  15.     B and C, they as listed as
  16.     Procedure A
  17.         Procedure B
  18.         Procedure C
  19.     If a procedure D makes a function call through a switch table, switching on
  20.     something called "type" to call procedure E, it is listed
  21.     as
  22.     Procedure D
  23.         ||
  24.       type=x
  25.         ||
  26.     Procedure E
  27.  
  28.     RPC's are shown with arrows: ||
  29.                  \/
  30.     Enjoy
  31.     
  32.  
  33. Fs_Open
  34. 1) Fsprefix_LookupOperation(name, operation, ..., &openResults, ...)
  35. 2) streamPtr = Fsio_StreamAddClient(&openResults.streamID, ...)
  36. 3) fsio_StreamOpTable[type].ioOpen(openResults and streamData)
  37.  
  38. 1) Fsprefix_LookupOperation(operation)
  39.     domainType = GetPrefix(fileName)
  40.     fs_DomainLookup[domainType][operation]
  41.         //                    \\
  42.     op=FS_DOMAIN_OPEN, domainType=FS_LOCAL_DOMAIN    REMOTE
  43.     //                          \\
  44. FslclOpen                        FsrmtOpen (see below)
  45.     FslclLookup()
  46.     fsio_OpenOpTable[descPtr->fileType].nameOpen
  47.         //                \\                
  48.     type=FS_FILE            type=FS_DEVICE
  49.     //                  \\
  50. Fsio_FileNameOpen            Fsio_DeviceNameOpen
  51.     Does some "ioOpen"                Sets up ioServerID and whether
  52.     stuff to avoid doing            device is remote or local to
  53.     extra rpc for files:            client.  This is for later
  54.     cache consistency.                ioOpen operation.
  55.  
  56.  
  57.  
  58. FsrmtOpen (continued)
  59.     RPC to Fsrmt_RpcOpen
  60.     ||
  61.         \/
  62. Fsrmt_RpcOpen
  63.     prefixHandlePtr =
  64.         fsio_StreamOpTable[prefixID.type].clientVerify(..., &domainType, ..)
  65.     fs_DomainLookup[domainType][operation]
  66.         //
  67.     op=FS_DOMAIN_OPEN, domainType=FS_LOCAL_DOMAIN
  68.      //
  69. FslclOpen (as above)
  70.  
  71.  
  72.  
  73. 3) fsio_StreamOpTable[type].ioOpen
  74.         //                ||            \\
  75.     type=FSIO_LCL_FILE_STREAM    FSIO_RMT_FILE_STREAM    FSIO_RMT_DEVICE_STREAM
  76.      //                ||              \\
  77. Fsio_FileIoOpen            FsrmtFileIoOpen        FsrmtDeviceIoOpen
  78.     Sets up stream for local        Set up a stream        Sets type to LCL.
  79.     disk file.  Consistency        for a remote file.        Fsrmt_DeviceOpen
  80.     and stuff was done in        This means setting        (see below)
  81.     name open, above.            up the recovery
  82.                     use counts.
  83.  
  84. Fsrmt_DeviceOpen (continued)
  85.     RPC to Fsrmt_RpcDevOpen
  86.     ||
  87.     \/
  88. Fsrmt_RpcDevOpen
  89.     Maps rmt to lcl type.
  90.     fsio_StreamOpTable[type].ioOpen
  91.         //
  92.     type=FSIO_LCL_DEVICE_STREAM
  93.      //
  94. Fsio_DeviceIoOpen
  95.     devFsOpTable[devHandlePtr->device.type].open to device-specific open proc.
  96.     consistency
  97.  
  98. ******************************************************************************
  99. And now back to our regularly-scheduled programming:
  100.  
  101. /*
  102.  * OPEN SWITCH
  103.  * The nameOpen procedure is used on the file server when opening streams or
  104.  * setting up an I/O fileID for a file or device.  It is keyed on
  105.  * disk file descriptor types( i.e. FS_FILE, FS_DIRECTORY, FS_DEVICE,
  106.  * FS_PSEUDO_DEVICE).  The nameOpen procedure returns an ioFileID
  107.  * used for I/O on the file, plus other data needed for the client's
  108.  * stream.  The streamIDPtr is NIL during set/get attributes, which
  109.  * indicates that the extra stream information isn't needed.
  110.  */
  111.  
  112. typedef struct Fsio_OpenOps {
  113.     int        type;            /* One of the file descriptor types */
  114.     /*
  115.      * The calling sequence for the nameOpen routine is:
  116.      *    FooNameOpen(handlePtr, clientID, useFlags, ioFileIDPtr, streamIDPtr,
  117.      *            sizePtr, dataPtr)
  118.      *        Fsio_FileIOHandle    *handlePtr;
  119.      *        int            clientID;
  120.      *        int            useFlags;    (From the stream)
  121.      *        Fs_FileID        ioFileIDPtr;    (Returned to client)
  122.      *       (The following arguments are ignored during set/get attrs)
  123.      *       (This case is indicated by a NIL streamIDPtr)
  124.      *        Fs_FileID        streamIDPtr;    (Returned to client,)
  125.      *        int            *sizePtr;    (Return size of data)
  126.      *        ClientData        *dataPtr;    (Extra return data)
  127.      */
  128.     ReturnStatus (*nameOpen)();
  129. } Fsio_OpenOps;
  130. /*
  131.  * The OpenOps are called to do preliminary open-time processing.  They
  132.  * are called after pathname resolution has obtained a local file I/O handle
  133.  * that represents a name of some object.  The NameOpen routine maps
  134.  * the attributes kept with the local file into an objectID (Fs_FileID)
  135.  * and any other information needed to create an I/O stream to the object.
  136.  */
  137. This goes into fsio_OpenOpTable
  138. static Fsio_OpenOps ioOpenOps[] = { 
  139.     /*
  140.      * FILE through SYMBOLIC_LINK are all the same.
  141.      */
  142.     { FS_FILE, Fsio_FileNameOpen },
  143.     { FS_DIRECTORY, Fsio_FileNameOpen },
  144.     { FS_SYMBOLIC_LINK, Fsio_FileNameOpen },
  145.     /*
  146.      * Remote devices are opened like ordinary devices, so the old
  147.      * remote-device type is unused.
  148.      */
  149.     { FS_DEVICE, Fsio_DeviceNameOpen },
  150.     /*
  151.      * Local pipes.
  152.      */
  153.     { FS_LOCAL_PIPE, Fsio_NoProc},
  154.     /*
  155.      * Named pipes.  Unimplemented, treat like a regular file.
  156.      */
  157.     { FS_NAMED_PIPE, Fsio_FileNameOpen },
  158.     /*
  159.      * Special file type for testing new kinds of files.
  160.      */
  161.     { FS_XTRA_FILE, Fsio_FileNameOpen},
  162. };
  163.     /*
  164.      * Pseudo devices.
  165.      */
  166. static Fsio_OpenOps pdevOpenOps[] = { 
  167.     /*
  168.      * Pseudo devices.
  169.      */
  170.     {FS_PSEUDO_DEV, FspdevNameOpen},
  171.     { FS_PSEUDO_FS, Fsio_NoProc},
  172.     /*
  173.      * A remote link can either be treated like a regular file,
  174.      * or opened by a pseudo-filesystem server.
  175.      */
  176.     { FS_REMOTE_LINK, FspdevRmtLinkNameOpen },
  177. };
  178.  
  179. /*
  180.  * Stream Types:
  181.  *    FSIO_STREAM        Top level type for stream with offset.  Streams
  182.  *                have an ID and are in the handle table to
  183.  *                support migration and shared stream offsets.
  184.  * The remaining types are for I/O handles
  185.  *    FSIO_LCL_FILE_STREAM    For a regular disk file stored locally.
  186.  *    FSIO_RMT_FILE_STREAM    For a remote Sprite file.
  187.  *    FSIO_LCL_DEVICE_STREAM    For a device on this host.
  188.  *    FSIO_RMT_DEVICE_STREAM    For a remote device.
  189.  *    FSIO_LCL_PIPE_STREAM    For an anonymous pipe buffered on this host.
  190.  *    FSIO_RMT_PIPE_STREAM    For an anonymous pipe bufferd on a remote host.
  191.  *                This type arises from process migration.
  192.  *    FSIO_CONTROL_STREAM    This is the stream used by the server for
  193.  *                a pseudo device to listen for new clients.
  194.  *    FSIO_SERVER_STREAM    The main state for a pdev request-response
  195.  *                connection.  Refereneced by the server's stream.
  196.  *    FSIO_LCL_PSEUDO_STREAM    A client's handle on a request-response
  197.  *                connection to a local pdev server.
  198.  *    FSIO_RMT_PSEUDO_STREAM    As above, but when the pdev server is remote.
  199.  *    FSIO_PFS_CONTROL_STREAM    Control stream for pseudo-filesystems.
  200.  *    FSIO_PFS_NAMING_STREAM    The request-response stream used for naming
  201.  *                operations in a pseudo-filesystem.  This
  202.  *                I/O handle is hung off the prefix table.
  203.  *    FSIO_LCL_PFS_STREAM    A clients' handle on a request-response
  204.  *                connection to a local pfs server.
  205.  *    FSIO_RMT_PFS_STREAM    As above, but when the pfs server is remote.
  206.  *    FSIO_RMT_CONTROL_STREAM    Needed only during get/set I/O attributes of
  207.  *                a pseudo-device whose server is remote.
  208.  *    FSIO_PASSING_STREAM    Used to pass streams from a pseudo-device
  209.  *                server to its client in response to an open.
  210.  *        Internet Protocols (Not implemented in the kernel (yet?))
  211.  *    FSIO_RAW_IP_STREAM    Raw Internet Protocol stream.
  212.  *    FSIO_UDP_STREAM        UDP protocol stream.
  213.  *    FSIO_TCP_STREAM        TCP protocol stream.
  214.  *
  215.  * The following streams are not implemented
  216.  *    FS_RMT_NFS_STREAM    NFS access implemented in kernel.
  217.  *    FS_RMT_UNIX_STREAM    For files on the old hybrid unix/sprite server.
  218.  *    FS_LCL_NAMED_PIPE_STREAM Stream to a named pipe whose backing file
  219.  *                is on the local host.
  220.  *    FS_RMT_NAMED_PIPE_STREAM Stream to a named pipe whose backing file
  221.  *                is remote. 
  222.  */
  223. /*
  224.  * STREAM SWITCH
  225.  *    These procedures are called by top-level procedures (i.e. Fs_Read,
  226.  *    or Fs_Select) to do stream-type specific processing.
  227.  */
  228.  
  229. typedef struct Fsio_StreamTypeOps {
  230.     int        type;            /* Stream types defined in fs.h */
  231.     /*
  232.      **************** Setup operation for clients. *************************
  233.      *    This routine sets up an I/O handle for a stream.  It uses streamData
  234.      *  that was genereated by the nameOpen routine on the file server.  As
  235.      *  a side effect it fills in the nameInfoPtr->fileID for use later
  236.      *  when getting/setting attributes.
  237.      *
  238.      *    FooIoOpen(ioFileIDPtr, flagsPtr, clientID, data, name, hdrPtrPtr)
  239.      *        Fs_FileID    *ioFileIDPtr;    (indicates object)
  240.      *        int        *flagsPtr;    (from the stream)
  241.      *        int        clientID;    (who's opening it)
  242.      *        ClientData    data;        (stream data from nameOpen)
  243.      *        char         *name;        (name for error messages)
  244.      *        Fs_HandleHeader    **hdrPtrPtr;    (Returned I/O handle)
  245.      */
  246.     ReturnStatus (*ioOpen)();
  247.     /*
  248.      **************** Regular I/O operations. ******************************
  249.      *  These are the standard read/write routines.  Note:  they are passed
  250.      *  a stream pointer to support streams shared accross the network.
  251.      *  A shared stream is indicated by FS_RMT_SHARED in the ioPtr->flags.
  252.      *    Note that only the fileID and the ioHandlePtr of the streamPtr
  253.      *    is guaranteed to be valid.  The stream-specific routine should ignore
  254.      *    the flags and offset kept (or not kept) in the stream structure.
  255.      *
  256.      *    FooRead(streamPtr, ioPtr, waitPtr, replyPtr)
  257.      *    FooWrite(streamPtr, ioPtr, waitPtr, replyPtr)
  258.      *        Fs_Stream    *streamPtr;    (See above about valid fields )
  259.      *        Fs_IOParam    *ioPtr;        (Standard parameter block)
  260.      *        Sync_RemoteWaiter *waitPtr;    (For remote waiting)
  261.      *        Fs_IOReply    *reply;        (For return length and signal)
  262.      */
  263.     ReturnStatus (*read)();
  264.     ReturnStatus (*write)();
  265.     /*
  266.      **************** VM I/O operations. ******************************
  267.      *  These are the read/write routines used by VM during paging.
  268.      *    The interface is the same as the regular read and write routines,
  269.      *    so those routines can be re-used, if appropriate.
  270.      *
  271.      *    FooPageRead(streamPtr, ioPtr, waitPtr, replyPtr)
  272.      *    FoPageoWrite(streamPtr, ioPtr, waitPtr, replyPtr)
  273.      *        Fs_Stream    *streamPtr;    (See above about valid fields)
  274.      *        Fs_IOParam    *ioPtr;        (Standard parameter block)
  275.      *        Sync_RemoteWaiter *waitPtr;    (For remote waiting)
  276.      *        Fs_IOReply    *reply;        (For return length and signal)
  277.      */
  278.     ReturnStatus (*pageRead)();
  279.     ReturnStatus (*pageWrite)();
  280.     /*
  281.      ***************** I/O Control. ****************************************
  282.      *  Stream-specific I/O controls.  The main procedure Fs_IOControl
  283.      *    handles some generic I/O controls, and then passes the I/O control
  284.      *    down to the stream-specific handler.
  285.      *
  286.      *    FooIOControl(hdrPtr, command, byteOrder, inBufSize, inBuf, outBufSize, outBuf)
  287.      *        Fs_HandleHeader *hdrPtr;            (File handle)
  288.      *        int        command;        (Special operation)
  289.      *        int        byteOrder;        (client's byte order)
  290.      *        int        inBufSize;        (Size of inBuf)
  291.      *        Address        inBuf;            (Input data)
  292.      *        int        outBufSize;        (Size of outBuf)
  293.      *        Address        outBuf;            (Return data)
  294.      */
  295.     ReturnStatus (*ioControl)();
  296.     /*
  297.      ***************** Select. *********************************************
  298.      *  The select interface includes three In/Out bit words.  There is
  299.      *  at most one bit set in each, and the selectability can be easily
  300.      *  turned off by clearing the word.  Never do anything to these
  301.      *  words other than leave them alone or clear them.
  302.      *
  303.      *    FooSelect(hdrPtr, waitPtr, readPtr, writePtr, exceptPtr)
  304.      *        Fs_HandleHeader        *hdrPtr;    (File handle)
  305.      *        Sync_RemoteWaiter    *waitPtr;    (Remote waiting info)
  306.      *        int            *readPtr;    (In/Out read bit)
  307.      *        int            *writePtr;    (In/Out write bit)
  308.      *        int            *exceptPtr;    (In/Out except bit)
  309.      */
  310.     ReturnStatus (*select)();
  311.     /*
  312.      **************** Attribute operations on open streams. *****************
  313.      *    These just operate on the few attributes cached at the I/O server.
  314.      *  The name server is first contacted to set/initialize the attributes,
  315.      *  (either via the DOMAIN switch with pathnames,
  316.      *  or via the ATTRIBUTE switch with open streams)
  317.      *  and then these routines are called to complete the attributes from
  318.      *  ones cached on the I/O server, or to update the ones cached there.
  319.      *
  320.      *    FooGetIOAttr(fileIDPtr, clientID, attrPtr)
  321.      *    FooSetIOAttr(fileIDPtr, attrPtr, flags)
  322.      *        Fs_FileID        *fileIDPtr;    (Identfies file)
  323.      *        int            clientID;    (Client getting attrs)
  324.      *        Fs_Attributes        *attrPtr;    (Attrs to set/update)
  325.      *        int            flags;        (which attrs to set)
  326.      */
  327.     ReturnStatus (*getIOAttr)();
  328.     ReturnStatus (*setIOAttr)();
  329.     /*
  330.      **************** Server verification of remote handle. *****************
  331.      *    This returns the server's file handle given a client's fileID.
  332.      *  There are two parts to this task.  The first is to map from the
  333.      *  client's fileID.type (i.e. FSIO_RMT_DEVICE_STREAM) to the server's
  334.      *  (i.e. FSIO_LCL_DEVICE_STREAM).  The second step is to check that the
  335.      *  client is recorded in the clientList of the I/O handle.  The domain
  336.      *    type is returned for use in naming operations.
  337.      *
  338.      *    Fs_HandleHeader *
  339.      *    FooClientVerify(fileIDPtr, clientID, domainTypePtr)
  340.      *        Fs_FileID    *fileIDPtr;        (Client's handle)
  341.      *        int        clientID;        (The client hostID)
  342.      *        int        *domainTypePtr;        (may be NIL)
  343.      */
  344.     Fs_HandleHeader *(*clientVerify)();
  345.     /*
  346.      *************** Migration calls. **************************************
  347.      *
  348.      *  The 'release' is called on the source client of migration via an RPC
  349.      *        from the I/O server.  Its job is to release any referneces
  350.      *        on the I/O handle that were due to a stream which has
  351.      *        now migrated away from the source client.
  352.      *  The 'migrate' is called from Fsio_DeencapStream to update client
  353.      *        book-keeping to reflect the migration.  The version on
  354.      *        remote clients just does an RPC to the I/O server to
  355.      *        invoke the appropriate migrate routine there.
  356.      *        Important:  If the FS_RMT_SHARED flag is present it means
  357.      *        that there is still a stream on the original client and its
  358.      *        references should not be removed from the I/O handle.
  359.      *        Also, if the FS_NEW_STREAM flag is present it means that
  360.      *        the stream is newly migrated to the client so references
  361.      *        should be added for the dstClient.
  362.      *  The 'migEnd' is called from Fsio_DeencapStream after the call to the
  363.      *        migrate procedure, but only the first time the stream
  364.      *        is migrated to the host.  (After that it suffices to
  365.      *        add references to the existing stream.)
  366.      *
  367.      *    FooRelease(hdrPtr, flags)
  368.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  369.      *        int        flags;            (From the stream)
  370.      *    FooMigEnd(migInfoPtr, size, data, hdrPtrPtr)
  371.      *        FsMigInfo    migInfoPtr;        (Migration state)
  372.      *        int        size;            (size of data)
  373.      *        ClientData    data;            (data from migrate)
  374.      *        Fs_HandleHeader    **hdrPtrPtr;        (Returned handle)
  375.      *    FooSrvMigrate(migInfoPtr, dstClientID, flagsPtr, offsetPtr sizePtr, dataPtr)
  376.      *        FsMigInfo    *migInfoPtr;        (Migration state)
  377.      *        int        dstClientID;        (ID of target client)
  378.      *        int        *flagsPtr;        (In/Out Stream flags)
  379.      *        int        *offsetPtr;        (Return - new offset)
  380.      *        int        *sizePtr;        (Return - size of data)
  381.      *        Address        *dataPtr;        (Return data)
  382.      */
  383.     ReturnStatus (*release)();
  384.     ReturnStatus (*migEnd)();
  385.     ReturnStatus (*migrate)();
  386.     /*
  387.      *************** Recovery calls. ****************************************
  388.      *  This (should be) two routines, one called on client host's top
  389.      *    reopen at the server, and one called on the server in response
  390.      *  to a client's reopen request.
  391.      *
  392.      *    FooReopen(hdrPtr, clientID, inData, outSizePtr, outDataPtr)
  393.      *        (The hdrPtr is only valid on clients.)
  394.      *        Fs_HandleHeader *hdrPtr;        (Handle to re-open)
  395.      *        (The following are only valid on servers.)
  396.      *        int        clientID;    (client doing the re-open)
  397.      *        ClientData    inData;        (state from the client)
  398.      *        int        *outSizePtr;    (sizeof outData)
  399.      *        ClientData    *outDataPtr;    (state returned to client)
  400.      */
  401.     ReturnStatus (*reopen)();
  402.     /*
  403.      *************** Clean up operations. **********************************
  404.      * 'scavenge' is called periodically to clean up unneeded handles.
  405.      *        Important: the scavenge procedure must either remove or
  406.      *        unlock the handle it is still in use.
  407.      * 'clientKill' is called to clean up after dead clients.  This is
  408.      *        called before the scavenge routine if a periodic check
  409.      *        on the client fails, or called independently if some other
  410.      *        communication failure occurs.
  411.      * 'close' is called when the last reference to a stream is closed.
  412.      *        This routine should clean up any use/reference counts
  413.      *        due to the stream as indicated by the flags argument.
  414.      *
  415.      *    FooScavenge(hdrPtr)
  416.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  417.      *    FooClientKill(hdrPtr, clientID)
  418.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  419.      *        int        clientID;        (Client presumed down)
  420.      *    FooClose(hdrPtr, clientID, procID, flags, size, data)
  421.      *        Fs_HandleHeader    *hdrPtr;        (File handle)
  422.      *        int        clientID;        (Host ID of closer)
  423.      *        Proc_Pid    procID;            (ProcessID of closer)
  424.      *        int        flags;            (From the stream)
  425.      *        int        size;            (Size of data)
  426.      *        ClientData    data;            (Extra close data)
  427.      */
  428.     Boolean     (*scavenge)();
  429.     void     (*clientKill)();
  430.     ReturnStatus (*close)();
  431. } Fsio_StreamTypeOps;
  432. /*
  433.  * Streams for Local files, device, and pipes
  434.  */
  435.  
  436. This goes into fsio_StreamOpTable:
  437. static Fsio_StreamTypeOps ioStreamOps[] = {
  438.     /*
  439.      * Top level stream.  This is created by Fs_Open and returned to clients.
  440.      * This in turn references a I/O handle of a different stream type.  The
  441.      * main reason this exists as a handle is so that it can be found
  442.      * during various cases of migration, although the reopen and scavenge
  443.      * entry points in this table are used.
  444.      */
  445.     { FSIO_STREAM, Fsio_NoProc, Fsio_NoProc, Fsio_NoProc,/* open, read, write */
  446.         Fsio_NoProc, Fsio_NoProc,    /* pageRead, pageWrite */
  447.         Fsio_NoProc, Fsio_NoProc,    /* iocontrol, select */
  448.         Fsio_NoProc, Fsio_NoProc,    /* getIOAttr, setIOAttr */
  449.         Fsio_NoHandle,            /* clientVerify */
  450.         Fsio_NoProc, Fsio_NoProc,    /* release, migEnd */
  451.         Fsio_NoProc,            /* migrate */
  452.         Fsio_StreamReopen,
  453.         (Boolean (*)())NIL,        /* scavenge */
  454.         Fsio_NullClientKill,
  455.         Fsio_NoProc},            /* close */
  456.     /*
  457.      * Local file stream.  The file is on a local disk and blocks are
  458.      * cached in the block cache.  The GetIOAttr(SetIOAttr) routine
  459.      * is Fsio_NullProc because all the work of getting(setting) cached attributes
  460.      * is already done by FslclGetAttr(FslclSetAttr).
  461.      */
  462.     { FSIO_LCL_FILE_STREAM, Fsio_FileIoOpen, Fsio_FileRead, Fsio_FileWrite,
  463.         Fsio_FileRead, Fsio_FileWrite,        /* Paging routines */
  464.         Fsio_FileIOControl, Fsio_FileSelect,
  465.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  466.         Fsio_NoHandle, Fsio_FileMigClose, Fsio_FileMigOpen, Fsio_FileMigrate,
  467.         Fsio_FileReopen,
  468.         Fsio_FileScavenge, Fsio_FileClientKill, Fsio_FileClose},
  469.     /*
  470.      * Local device stream.  These routines branch to the device driver
  471.      * for the particular device type.
  472.      */
  473.     { FSIO_LCL_DEVICE_STREAM, Fsio_DeviceIoOpen, Fsio_DeviceRead, Fsio_DeviceWrite,
  474.         Fsio_NoProc, Fsio_NoProc,        /* Paging routines */
  475.         Fsio_DeviceIOControl, Fsio_DeviceSelect,
  476.         Fsio_DeviceGetIOAttr, Fsio_DeviceSetIOAttr,
  477.         Fsio_NoHandle,                /* clientVerify */
  478.         Fsio_DeviceMigClose, Fsio_DeviceMigOpen, Fsio_DeviceMigrate,
  479.         Fsrmt_DeviceReopen,
  480.         Fsio_DeviceScavenge, Fsio_DeviceClientKill, Fsio_DeviceClose},
  481.     /*
  482.      * Local anonymous pipe stream.  
  483.      */
  484.     { FSIO_LCL_PIPE_STREAM, Fsio_NoProc, Fsio_PipeRead, Fsio_PipeWrite,
  485.         Fsio_NoProc, Fsio_NoProc,        /* Paging routines */
  486.         Fsio_PipeIOControl, Fsio_PipeSelect,
  487.         Fsio_PipeGetIOAttr, Fsio_PipeSetIOAttr,
  488.         Fsio_NoHandle,                /* clientVerify */
  489.         Fsio_PipeMigClose, Fsio_PipeMigOpen, Fsio_PipeMigrate,
  490.         Fsio_PipeReopen,
  491.         Fsio_PipeScavenge, Fsio_PipeClientKill, Fsio_PipeClose},
  492.  
  493. };
  494.  
  495. /*
  496.  * File stream type ops for FSIO_RMT_FILE_STREAM, FSIO_RMT_DEVICE_STREAM,
  497.  * and FSIO_RMT_PIPE_STREAM;
  498.  */
  499.  
  500. static Fsio_StreamTypeOps rmtFileStreamOps[] = {
  501. /*
  502.  * Remote file stream.  The file is at a remote server but blocks might 
  503.  * be cached in the block cache.
  504.  */
  505.     { FSIO_RMT_FILE_STREAM, FsrmtFileIoOpen, FsrmtFileRead, FsrmtFileWrite,
  506.         FsrmtFilePageRead, FsrmtFilePageWrite,
  507.         FsrmtFileIOControl, Fsio_FileSelect,
  508.         FsrmtFileGetIOAttr, FsrmtFileSetIOAttr,
  509.         FsrmtFileVerify, FsrmtFileMigClose, FsrmtFileMigOpen,
  510.         FsrmtFileMigrate, FsrmtFileReopen,
  511.         FsrmtFileScavenge,
  512.         Fsio_NullClientKill, FsrmtFileClose},
  513. /*
  514.  * Remote device stream.  Forward the operations to the remote I/O server.
  515.  */
  516.     { FSIO_RMT_DEVICE_STREAM, FsrmtDeviceIoOpen, Fsrmt_Read, Fsrmt_Write,
  517.         Fsio_NoProc, Fsio_NoProc,    /* Paging routines */
  518.         Fsrmt_IOControl, Fsrmt_Select,
  519.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  520.         FsrmtDeviceVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  521.         FsrmtDeviceMigrate, FsrmtDeviceReopen,
  522.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  523.  /*
  524.   * Remote anonymous pipe stream.  These arise because of migration.
  525.   */
  526.     { FSIO_RMT_PIPE_STREAM, Fsio_NoProc, Fsrmt_Read, Fsrmt_Write,
  527.         Fsio_NoProc, Fsio_NoProc,    /* Paging routines */
  528.         Fsrmt_IOControl, Fsrmt_Select,
  529.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  530.         FsrmtPipeVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  531.         FsrmtPipeMigrate, FsrmtPipeReopen,
  532.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  533. };
  534. /*
  535.  * File stream type ops for FSIO_CONTROL_STREAM, FSIO_SERVER_STREAM,
  536.  * and FSIO_LCL_PSEUDO_STREAM FSIO_RMT_PSEUDO_STREAM FSIO_PFS_CONTROL_STREAM
  537.  * FSIO_PFS_NAMING_STREAM FSIO_LCL_PFS_STREAM FSIO_RMT_CONTROL_STREAM 
  538.  * FSIO_PASSING_STREAM
  539.  */
  540.  
  541. static Fsio_StreamTypeOps pdevFileStreamOps[] = {
  542.     /*
  543.      * A control stream is what a pdev server process gets when it opens a
  544.      * pseudo device file.  This stream is used to notify the server
  545.      * of new clients; the ID of the server stream set up for each
  546.      * new client is passed over this control stream.
  547.      */
  548.     { FSIO_CONTROL_STREAM, FspdevControlIoOpen,
  549.         FspdevControlRead, Fsio_NoProc,
  550.         Fsio_NoProc, Fsio_NoProc,        /* Paging routines */
  551.         FspdevControlIOControl, FspdevControlSelect,
  552.         FspdevControlGetIOAttr, FspdevControlSetIOAttr,
  553.         FspdevControlVerify,
  554.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  555.         Fsio_NoProc, FspdevControlReopen,    /* migrate, reopen */
  556.         FspdevControlScavenge, FspdevControlClientKill,
  557.         FspdevControlClose },
  558.     /*
  559.      * A server stream gets set up for the server whenever a client opens
  560.      * a pseudo device.  The server reads the stream the learn about new
  561.      * requests from the client.  IOControls on the stream are used
  562.      * to control the connection to the client.
  563.      */
  564.     { FSIO_SERVER_STREAM, Fsio_NoProc,
  565.         FspdevServerStreamRead, Fsio_NoProc,
  566.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  567.         FspdevServerStreamIOControl, FspdevServerStreamSelect,
  568.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  569.         Fsio_NoHandle,                /* verify */
  570.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  571.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  572.         (Boolean (*)())NIL,            /* scavenge */
  573.         Fsio_NullClientKill, FspdevServerStreamClose },
  574.     /*
  575.      * A pseudo stream with the server process running locally.  
  576.      */
  577.     { FSIO_LCL_PSEUDO_STREAM, FspdevPseudoStreamIoOpen,
  578.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite,
  579.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite, /* Paging */
  580.         FspdevPseudoStreamIOControl,
  581.         FspdevPseudoStreamSelect,
  582.         FspdevPseudoStreamGetIOAttr, FspdevPseudoStreamSetIOAttr,
  583.         Fsio_NoHandle,                /* verify */
  584.         FspdevPseudoStreamMigClose, FspdevPseudoStreamMigOpen,
  585.         FspdevPseudoStreamMigrate,
  586.         Fsio_NoProc,                /* reopen */
  587.         (Boolean (*)())NIL,            /* scavenge */
  588.         Fsio_NullClientKill, FspdevPseudoStreamClose },
  589.     /*
  590.      * A pseudo stream with a remote server.  
  591.      */
  592.     { FSIO_RMT_PSEUDO_STREAM, FspdevRmtPseudoStreamIoOpen,
  593.         Fsrmt_Read, Fsrmt_Write,
  594.         Fsrmt_Read, Fsrmt_Write,        /* Paging I/O */
  595.         Fsrmt_IOControl, Fsrmt_Select,
  596.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  597.         FspdevRmtPseudoStreamVerify,
  598.         Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  599.         FspdevRmtPseudoStreamMigrate,
  600.         Fsio_NoProc,                /* reopen */
  601.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  602.         Fsrmt_IOClose },
  603.     /*
  604.      * A control stream used to mark the existence of a pseudo-filesystem.
  605.      * The server doesn't do I/O to this stream; it is only used at
  606.      * open and close time.
  607.      */
  608.     { FSIO_PFS_CONTROL_STREAM, FspdevPfsIoOpen,
  609.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  610.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  611.         Fsio_NoProc, Fsio_NoProc,        /* IOControl, select */
  612.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  613.         FspdevControlVerify,
  614.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  615.         Fsio_NoProc, FspdevControlReopen,    /* migrate, reopen */
  616.         FspdevControlScavenge, FspdevControlClientKill,
  617.         FspdevControlClose },
  618.     /*
  619.      * The 'naming stream' for a pseudo-filesystem is used to forward lookup
  620.      * operations from the kernel up to the user-level server.  It is like
  621.      * a regular pdev request-response stream, except that extra connections
  622.      * to it are established via the prefix table when remote Sprite hosts
  623.      * import a pseudo-filesystem.  The routines here are used to set this up.
  624.      * This stream is only accessed locally.  To remote hosts the domain is
  625.      * a regular remote sprite domain, and the RPC stubs on the server then
  626.      * switch out to either local-domain or pseudo-domain routines.
  627.      */
  628.     { FSIO_PFS_NAMING_STREAM, FspdevPfsNamingIoOpen,
  629.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  630.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  631.         Fsio_NoProc, Fsio_NoProc,        /* IOControl, select */
  632.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  633.         FspdevRmtPseudoStreamVerify,
  634.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  635.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  636.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  637.         Fsrmt_IOClose },
  638.     /*
  639.      * A pseudo stream to a pseudo-filesystem server.  This is just like
  640.      * a pseudo stream to a pseudo-device server, except for the CltOpen
  641.      * routine because setup is different.  
  642.      */
  643.     { FSIO_LCL_PFS_STREAM, FspdevPfsStreamIoOpen,
  644.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite,
  645.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite, /* Paging */
  646.         FspdevPseudoStreamIOControl,
  647.         FspdevPseudoStreamSelect,
  648.         FspdevPseudoStreamGetIOAttr, FspdevPseudoStreamSetIOAttr,
  649.         Fsio_NoHandle,                    /* verify */
  650.         FspdevPseudoStreamMigClose, FspdevPseudoStreamMigOpen,
  651.         FspdevPseudoStreamMigrate,
  652.         Fsio_NoProc,                    /* reopen */
  653.         (Boolean (*)())NIL,                /* scavenge */
  654.         Fsio_NullClientKill, FspdevPseudoStreamClose },
  655.     /*
  656.      * A pseudo stream to a remote pseudo-filesystem server.  This is
  657.      * like the remote pseudo-device stream, except for setup because the
  658.      * pseudo-device connection is already set up by the time the
  659.      * CltOpen routine is called.
  660.      */
  661.     { FSIO_RMT_PFS_STREAM, FspdevRmtPfsStreamIoOpen,
  662.         Fsrmt_Read, Fsrmt_Write,
  663.         Fsrmt_Read, Fsrmt_Write,            /* Paging */
  664.         Fsrmt_IOControl, Fsrmt_Select,
  665.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  666.         FspdevRmtPseudoStreamVerify,
  667.         Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  668.         FspdevRmtPseudoStreamMigrate,
  669.         Fsio_NoProc,                    /* reopen */
  670.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  671.         Fsrmt_IOClose },
  672.     /*
  673.      * This stream type is only used during get/set I/O attributes when
  674.      * the pseudo-device server is remote.  No handles of this type are
  675.      * actually created, only fileIDs that map to FSIO_CONTROL_STREAM.  
  676.      */
  677.     { FSIO_RMT_CONTROL_STREAM, Fsio_NoProc,        /* ioOpen */
  678.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  679.         Fsio_NoProc, Fsio_NoProc,        /* Paging */
  680.         Fsio_NoProc, Fsio_NoProc,        /* ioctl, select */
  681.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  682.         (Fs_HandleHeader *(*)())Fsio_NoProc,    /* verify */
  683.         Fsio_NoProc, Fsio_NoProc,        /* release, migend */
  684.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  685.         (Boolean (*)())NIL,            /* scavenge */
  686.         (void (*)())Fsio_NoProc, Fsio_NoProc },    /* kill, close */
  687.     /*
  688.      * Stream used to pass streams from a pseudo-device server to
  689.      * a client in response to an open request.
  690.      */
  691.     { FSIO_PASSING_STREAM, FspdevPassStream,
  692.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  693.         Fsio_NoProc, Fsio_NoProc,        /* Paging */
  694.         Fsio_NoProc, Fsio_NoProc,        /* ioctl, select */
  695.         Fsio_NoProc, Fsio_NoProc,        /* get/set attr */
  696.         (Fs_HandleHeader *(*)())Fsio_NoProc,    /* verify */
  697.         Fsio_NoProc, Fsio_NoProc,        /* release, migend */
  698.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  699.         (Boolean (*)())NIL,            /* scavenge */
  700.         (void (*)())Fsio_NoProc, Fsio_NoProc },    /* kill, close */
  701.  
  702.  
  703. };
  704.  
  705.  
  706. /*
  707.  * File stream type ops for FSIO_CONTROL_STREAM, FSIO_SERVER_STREAM,
  708.  * and FSIO_LCL_PSEUDO_STREAM FSIO_RMT_PSEUDO_STREAM FSIO_PFS_CONTROL_STREAM
  709.  * FSIO_PFS_NAMING_STREAM FSIO_LCL_PFS_STREAM FSIO_RMT_CONTROL_STREAM 
  710.  * FSIO_PASSING_STREAM
  711.  */
  712.  
  713. static Fsio_StreamTypeOps pdevFileStreamOps[] = {
  714.     /*
  715.      * A control stream is what a pdev server process gets when it opens a
  716.      * pseudo device file.  This stream is used to notify the server
  717.      * of new clients; the ID of the server stream set up for each
  718.      * new client is passed over this control stream.
  719.      */
  720.     { FSIO_CONTROL_STREAM, FspdevControlIoOpen,
  721.         FspdevControlRead, Fsio_NoProc,
  722.         Fsio_NoProc, Fsio_NoProc,        /* Paging routines */
  723.         FspdevControlIOControl, FspdevControlSelect,
  724.         FspdevControlGetIOAttr, FspdevControlSetIOAttr,
  725.         FspdevControlVerify,
  726.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  727.         Fsio_NoProc, FspdevControlReopen,    /* migrate, reopen */
  728.         FspdevControlScavenge, FspdevControlClientKill,
  729.         FspdevControlClose },
  730.     /*
  731.      * A server stream gets set up for the server whenever a client opens
  732.      * a pseudo device.  The server reads the stream the learn about new
  733.      * requests from the client.  IOControls on the stream are used
  734.      * to control the connection to the client.
  735.      */
  736.     { FSIO_SERVER_STREAM, Fsio_NoProc,
  737.         FspdevServerStreamRead, Fsio_NoProc,
  738.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  739.         FspdevServerStreamIOControl, FspdevServerStreamSelect,
  740.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  741.         Fsio_NoHandle,                /* verify */
  742.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  743.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  744.         (Boolean (*)())NIL,            /* scavenge */
  745.         Fsio_NullClientKill, FspdevServerStreamClose },
  746.     /*
  747.      * A pseudo stream with the server process running locally.  
  748.      */
  749.     { FSIO_LCL_PSEUDO_STREAM, FspdevPseudoStreamIoOpen,
  750.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite,
  751.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite, /* Paging */
  752.         FspdevPseudoStreamIOControl,
  753.         FspdevPseudoStreamSelect,
  754.         FspdevPseudoStreamGetIOAttr, FspdevPseudoStreamSetIOAttr,
  755.         Fsio_NoHandle,                /* verify */
  756.         FspdevPseudoStreamMigClose, FspdevPseudoStreamMigOpen,
  757.         FspdevPseudoStreamMigrate,
  758.         Fsio_NoProc,                /* reopen */
  759.         (Boolean (*)())NIL,            /* scavenge */
  760.         Fsio_NullClientKill, FspdevPseudoStreamClose },
  761.     /*
  762.      * A pseudo stream with a remote server.  
  763.      */
  764.     { FSIO_RMT_PSEUDO_STREAM, FspdevRmtPseudoStreamIoOpen,
  765.         Fsrmt_Read, Fsrmt_Write,
  766.         Fsrmt_Read, Fsrmt_Write,        /* Paging I/O */
  767.         Fsrmt_IOControl, Fsrmt_Select,
  768.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  769.         FspdevRmtPseudoStreamVerify,
  770.         Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  771.         FspdevRmtPseudoStreamMigrate,
  772.         Fsio_NoProc,                /* reopen */
  773.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  774.         Fsrmt_IOClose },
  775.     /*
  776.      * A control stream used to mark the existence of a pseudo-filesystem.
  777.      * The server doesn't do I/O to this stream; it is only used at
  778.      * open and close time.
  779.      */
  780.     { FSIO_PFS_CONTROL_STREAM, FspdevPfsIoOpen,
  781.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  782.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  783.         Fsio_NoProc, Fsio_NoProc,        /* IOControl, select */
  784.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  785.         FspdevControlVerify,
  786.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  787.         Fsio_NoProc, FspdevControlReopen,    /* migrate, reopen */
  788.         FspdevControlScavenge, FspdevControlClientKill,
  789.         FspdevControlClose },
  790.     /*
  791.      * The 'naming stream' for a pseudo-filesystem is used to forward lookup
  792.      * operations from the kernel up to the user-level server.  It is like
  793.      * a regular pdev request-response stream, except that extra connections
  794.      * to it are established via the prefix table when remote Sprite hosts
  795.      * import a pseudo-filesystem.  The routines here are used to set this up.
  796.      * This stream is only accessed locally.  To remote hosts the domain is
  797.      * a regular remote sprite domain, and the RPC stubs on the server then
  798.      * switch out to either local-domain or pseudo-domain routines.
  799.      */
  800.     { FSIO_PFS_NAMING_STREAM, FspdevPfsNamingIoOpen,
  801.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  802.         Fsio_NoProc, Fsio_NoProc,        /* Paging I/O */
  803.         Fsio_NoProc, Fsio_NoProc,        /* IOControl, select */
  804.         Fsio_NullProc, Fsio_NullProc,        /* Get/Set IO Attr */
  805.         FspdevRmtPseudoStreamVerify,
  806.         Fsio_NoProc, Fsio_NoProc,        /* migStart, migEnd */
  807.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  808.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  809.         Fsrmt_IOClose },
  810.     /*
  811.      * A pseudo stream to a pseudo-filesystem server.  This is just like
  812.      * a pseudo stream to a pseudo-device server, except for the CltOpen
  813.      * routine because setup is different.  
  814.      */
  815.     { FSIO_LCL_PFS_STREAM, FspdevPfsStreamIoOpen,
  816.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite,
  817.         FspdevPseudoStreamRead,    FspdevPseudoStreamWrite, /* Paging */
  818.         FspdevPseudoStreamIOControl,
  819.         FspdevPseudoStreamSelect,
  820.         FspdevPseudoStreamGetIOAttr, FspdevPseudoStreamSetIOAttr,
  821.         Fsio_NoHandle,                    /* verify */
  822.         FspdevPseudoStreamMigClose, FspdevPseudoStreamMigOpen,
  823.         FspdevPseudoStreamMigrate,
  824.         Fsio_NoProc,                    /* reopen */
  825.         (Boolean (*)())NIL,                /* scavenge */
  826.         Fsio_NullClientKill, FspdevPseudoStreamClose },
  827.     /*
  828.      * A pseudo stream to a remote pseudo-filesystem server.  This is
  829.      * like the remote pseudo-device stream, except for setup because the
  830.      * pseudo-device connection is already set up by the time the
  831.      * CltOpen routine is called.
  832.      */
  833.     { FSIO_RMT_PFS_STREAM, FspdevRmtPfsStreamIoOpen,
  834.         Fsrmt_Read, Fsrmt_Write,
  835.         Fsrmt_Read, Fsrmt_Write,            /* Paging */
  836.         Fsrmt_IOControl, Fsrmt_Select,
  837.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  838.         FspdevRmtPseudoStreamVerify,
  839.         Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  840.         FspdevRmtPseudoStreamMigrate,
  841.         Fsio_NoProc,                    /* reopen */
  842.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill,
  843.         Fsrmt_IOClose },
  844.     /*
  845.      * This stream type is only used during get/set I/O attributes when
  846.      * the pseudo-device server is remote.  No handles of this type are
  847.      * actually created, only fileIDs that map to FSIO_CONTROL_STREAM.  
  848.      */
  849.     { FSIO_RMT_CONTROL_STREAM, Fsio_NoProc,        /* ioOpen */
  850.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  851.         Fsio_NoProc, Fsio_NoProc,        /* Paging */
  852.         Fsio_NoProc, Fsio_NoProc,        /* ioctl, select */
  853.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  854.         (Fs_HandleHeader *(*)())Fsio_NoProc,    /* verify */
  855.         Fsio_NoProc, Fsio_NoProc,        /* release, migend */
  856.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  857.         (Boolean (*)())NIL,            /* scavenge */
  858.         (void (*)())Fsio_NoProc, Fsio_NoProc },    /* kill, close */
  859.     /*
  860.      * Stream used to pass streams from a pseudo-device server to
  861.      * a client in response to an open request.
  862.      */
  863.     { FSIO_PASSING_STREAM, FspdevPassStream,
  864.         Fsio_NoProc, Fsio_NoProc,        /* read, write */
  865.         Fsio_NoProc, Fsio_NoProc,        /* Paging */
  866.         Fsio_NoProc, Fsio_NoProc,        /* ioctl, select */
  867.         Fsio_NoProc, Fsio_NoProc,        /* get/set attr */
  868.         (Fs_HandleHeader *(*)())Fsio_NoProc,    /* verify */
  869.         Fsio_NoProc, Fsio_NoProc,        /* release, migend */
  870.         Fsio_NoProc, Fsio_NoProc,        /* migrate, reopen */
  871.         (Boolean (*)())NIL,            /* scavenge */
  872.         (void (*)())Fsio_NoProc, Fsio_NoProc },    /* kill, close */
  873.  
  874.  
  875. };
  876.  
  877. /*
  878.  * File stream type ops for FSIO_RMT_FILE_STREAM, FSIO_RMT_DEVICE_STREAM,
  879.  * and FSIO_RMT_PIPE_STREAM;
  880.  */
  881.  
  882. static Fsio_StreamTypeOps rmtFileStreamOps[] = {
  883. /*
  884.  * Remote file stream.  The file is at a remote server but blocks might 
  885.  * be cached in the block cache.
  886.  */
  887.     { FSIO_RMT_FILE_STREAM, FsrmtFileIoOpen, FsrmtFileRead, FsrmtFileWrite,
  888.         FsrmtFilePageRead, FsrmtFilePageWrite,
  889.         FsrmtFileIOControl, Fsio_FileSelect,
  890.         FsrmtFileGetIOAttr, FsrmtFileSetIOAttr,
  891.         FsrmtFileVerify, FsrmtFileMigClose, FsrmtFileMigOpen,
  892.         FsrmtFileMigrate, FsrmtFileReopen,
  893.         FsrmtFileScavenge,
  894.         Fsio_NullClientKill, FsrmtFileClose},
  895. /*
  896.  * Remote device stream.  Forward the operations to the remote I/O server.
  897.  */
  898.     { FSIO_RMT_DEVICE_STREAM, FsrmtDeviceIoOpen, Fsrmt_Read, Fsrmt_Write,
  899.         Fsio_NoProc, Fsio_NoProc,    /* Paging routines */
  900.         Fsrmt_IOControl, Fsrmt_Select,
  901.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  902.         FsrmtDeviceVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  903.         FsrmtDeviceMigrate, FsrmtDeviceReopen,
  904.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  905.  /*
  906.   * Remote anonymous pipe stream.  These arise because of migration.
  907.   */
  908.     { FSIO_RMT_PIPE_STREAM, Fsio_NoProc, Fsrmt_Read, Fsrmt_Write,
  909.         Fsio_NoProc, Fsio_NoProc,    /* Paging routines */
  910.         Fsrmt_IOControl, Fsrmt_Select,
  911.         Fsrmt_GetIOAttr, Fsrmt_SetIOAttr,
  912.         FsrmtPipeVerify, Fsrmt_IOMigClose, Fsrmt_IOMigOpen,
  913.         FsrmtPipeMigrate, FsrmtPipeReopen,
  914.         Fsutil_RemoteHandleScavenge, Fsio_NullClientKill, Fsrmt_IOClose},
  915. };
  916.  
  917. /*
  918.  * fs_DomainLookup:
  919.  * Domain specific routine table for lookup operations.
  920.  * The following operate on a single pathname.  They are called via
  921.  * Fsprefix_LookupOperation with arguments described in fsOpTable.h
  922.  *    DomainImport
  923.  *    DomainExport
  924.  *    DomainOpen
  925.  *    DomainGetAttrPath
  926.  *    DomainSetAttrPath
  927.  *    DomainMakeDevice
  928.  *    DomainMakeDir
  929.  *    DomainRemove
  930.  *    DomainRemoveDir
  931.  * The following operate on two pathnames.
  932.  *    DomainRename
  933.  *    DomainHardLink
  934.  */
  935.  
  936. /*
  937.  * THIS ARRAY INDEXED BY DOMAIN TYPE.  Do not arbitrarily insert entries.
  938.  */
  939. ReturnStatus (*fs_DomainLookup[FS_NUM_DOMAINS][FS_NUM_NAME_OPS])() = {
  940. /* FS_LOCAL_DOMAIN */
  941. /* FS_REMOTE_SPRITE_DOMAIN */
  942. /* FS_PSEUDO_DOMAIN */
  943. /* FS_NFS_DOMAIN */
  944. };
  945.  
  946. static ReturnStatus (*lclDomainLookup[FS_NUM_NAME_OPS])() = {
  947.      Fsio_NoProc, FslclExport, FslclOpen, FslclGetAttrPath,
  948.      FslclSetAttrPath, FslclMakeDevice, FslclMakeDir,
  949.      FslclRemove, FslclRemoveDir, FslclRename, FslclHardLink,
  950. };
  951. static ReturnStatus (*rmtDomainLookup[FS_NUM_NAME_OPS])() = {
  952.      FsrmtImport, Fsio_NoProc, FsrmtOpen, FsrmtGetAttrPath,
  953.      FsrmtSetAttrPath, FsrmtMakeDevice, FsrmtMakeDir, 
  954.      FsrmtRemove, FsrmtRemoveDir, FsrmtRename, FsrmtHardLink
  955. };
  956. static ReturnStatus (*pdevDomainLookup[FS_NUM_NAME_OPS])() = {
  957.      Fsio_NoProc, FspdevPfsExport, FspdevPfsOpen, FspdevPfsGetAttrPath, FspdevPfsSetAttrPath,
  958.      FspdevPfsMakeDevice, FspdevPfsMakeDir, FspdevPfsRemove, FspdevPfsRemoveDir,
  959.      FspdevPfsRename, FspdevPfsHardLink
  960. };
  961.  
  962. /*
  963.  * Domain specific get/set attributes table.  These routines are used
  964.  * to get/set attributes on the name server given a fileID (not a pathname).
  965.  */
  966. Fs_AttrOps fs_AttrOpTable[FS_NUM_DOMAINS] = {
  967. /* FS_LOCAL_DOMAIN */
  968. /* FS_REMOTE_SPRITE_DOMAIN */
  969. /* FS_PSEUDO_DOMAIN */
  970. /* FS_NFS_DOMAIN */
  971. };
  972. /*
  973.  * Domain specific get/set attributes table.  These routines are used
  974.  * to get/set attributes on the name server given a fileID (not a pathname).
  975.  */
  976. static Fs_AttrOps rmtAttrOpTable =   { FsrmtGetAttr, FsrmtSetAttr };
  977. static Fs_AttrOps lclAttrOpTable =   { FslclGetAttr, FslclSetAttr };
  978.  
  979. static Fs_AttrOps pdevAttrOpTable = { FspdevPseudoGetAttr, FspdevPseudoSetAttr };
  980. static Fs_AttrOps rmtAttrOpTable =   { FsrmtGetAttr, FsrmtSetAttr };
  981.  
  982.  
  983. Cache backend routines:
  984. typedef struct Fscache_BackendRoutines {
  985.     /*  
  986.      *  FooAllocate(hdrPtr, offset, bytes, flags, blockAddrPtr, newBlockPtr)
  987.      *          Fs_HandleHeader *hdrPtr;                        (File handle)
  988.      *          int             offset;                 (Byte offset)
  989.      *          int             bytes;                  (Bytes to allocate)
  990.      *          int             flags;                  (FSCACHE_DONT_BLOCK)
  991.      *          int             *blockAddrPtr;          (Returned block number)
  992.      *          Boolean         *newBlockPtr;           (TRUE if new block)
  993.      *  FooTruncate(hdrPtr, size, delete)
  994.      *          Fs_HandleHeader *hdrPtr;                (File handle)
  995.      *          int             size;                   (New size)
  996.      *          Boolean         delete;                 (TRUE if file being
  997.      *                                                   removed)
  998.      *  FooBlockRead(hdrPtr, blockPtr,remoteWaitPtr)
  999.      *          Fs_HandleHeader *hdrPtr;                (File handle)
  1000.      *          Fscache_Block   *blockPtr;              (Cache block to read)
  1001.      *          Sync_RemoteWaiter *remoteWaitPtr;       (For remote waiting)
  1002.      *  FooBlockWrite(hdrPtr, blockPtr, lastDirtyBlock)
  1003.      *          Boolean         lastDirtyBlock;         (Indicates last block)
  1004.      *  FooReallocBlock(data, callInfoPtr)
  1005.      *          ClientData      data =  blockPtr;  (Cache block to realloc)
  1006.      *          Proc_CallInfo   *callInfoPtr;
  1007.      *  FooStartWriteBack(backendPtr)
  1008.      *        Fscache_Backend *backendPtr;      (Backend to start writeback.)
  1009.      */
  1010.     ReturnStatus (*allocate) _ARGS_((Fs_HandleHeader *hdrPtr, int offset,
  1011.                                     int numBytes, int flags, int *blockAddrPtr,
  1012.                                     Boolean *newBlockPtr));
  1013.     ReturnStatus (*truncate) _ARGS_((Fs_HandleHeader *hdrPtr, int size,
  1014.                                      Boolean delete));
  1015.     ReturnStatus (*blockRead) _ARGS_((Fs_HandleHeader *hdrPtr,
  1016.                                       Fscache_Block *blockPtr,
  1017.                                       Sync_RemoteWaiter *remoteWaitPtr));
  1018.     ReturnStatus (*blockWrite) _ARGS_((Fs_HandleHeader *hdrPtr,
  1019.                                        Fscache_Block *blockPtr, int flags));
  1020.     void         (*reallocBlock) _ARGS_((ClientData data,
  1021.                                          Proc_CallInfo *callInfoPtr));
  1022.  
  1023.     ReturnStatus (*startWriteBack) _ARGS_((struct Fscache_Backend *backendPtr));
  1024. } Fscache_BackendRoutines;
  1025.  
  1026. static Fscache_BackendRoutines  ofsBackendRoutines = {
  1027.             Fsdm_BlockAllocate,
  1028.             Fsdm_FileTrunc,
  1029.             Fsdm_FileBlockRead,
  1030.             Fsdm_FileBlockWrite,
  1031.             Ofs_ReallocBlock,
  1032.             Ofs_StartWriteBack,
  1033. }
  1034.  
  1035. static Fscache_BackendRoutines  fsrmtBackendRoutines = {
  1036.             FsrmtFileBlockAllocate,
  1037.             FsrmtFileTrunc,
  1038.             FsrmtFileBlockRead,
  1039.             FsrmtFileBlockWrite,
  1040.             FsrmtReallocBlock,
  1041.             FsrmtStartWriteBack,
  1042. };
  1043.  
  1044. static Fscache_BackendRoutines  lfsBackendRoutines = {
  1045.             Fsdm_BlockAllocate,
  1046.             Fsdm_FileTrunc,
  1047.             Fsdm_FileBlockRead,
  1048.             Fsdm_FileBlockWrite,
  1049.             Lfs_ReallocBlock,
  1050.             Lfs_StartWriteBack,
  1051.  
  1052. };
  1053.